const path = require('path');
const resolve = (paths) => {
  return path.resolve(__dirname, paths);
};

const config = {
  publicPath: '/',
  outputDir: './dist/main',
  pages: {
    main: {
      entry: 'src/main/index.js',
      template: 'public/index.html',
      filename: 'main.html',
      title: '博客人生',
      chunks: ['chunk-vendors', 'chunk-common', 'main'],
    },
    login: {
      entry: 'src/login/index.js',
      template: 'public/index.html',
      filename: 'login.html',
      title: '登录',
      chunks: ['chunk-vendors', 'chunk-common', 'login'],
    },
  },
  devServer: {
    host: '0.0.0.0',
    port: 8020,
    proxy: {
      // detail: https://cli.vuejs.org/config/#devserver-proxy
      '/bgmg': {
        target: `http://127.0.0.1:8050/`,
        ws: true,
        changeOrigin: true,
      },
    },
  },
  lintOnSave: false,
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('./src'))
      .set('assets', resolve('./src/assets'))
      .set('router', resolve('./src/router'))
      .set('store', resolve('./src/store'))
      .set('views', resolve('./src/views'))
      .set('request', resolve('./src/request'));
  },
};

module.exports = config;
